<?php
require_once "config.php";
require_once "functions.php";
if(isset($_REQUEST['proId'])) {
    $flagexpander=0;
	$productId=$_REQUEST['proId'];
	$sNo=$_REQUEST['sno'];
	$imageExpand="<a href='javascript:void(0);' onClick='funContractProduct($productId,\"mchnt\",\"divSellingPro$productId\",$sNo)'><img src='images/16x16x-.jpg' border='0'></a>";
	$products=getProductById($productId);		
	if(!empty($products['shipping']))
		$productShipping=" + ".$products['shipping'];
	else
		$productShipping=" + Free";
	$sqlSelSellingNoBargain="SELECT * FROM tbl_items where product_id='$productId'  and seller_id!='$userId' and bargained=0";
	$rstSelSellingNoBargain=mysql_query($sqlSelSellingNoBargain);				
	$numSelSellingNoBargain=mysql_num_rows($rstSelSellingNoBargain);
	echo "<table width=100% border='0' align='center' cellspacing='0'>";
	if($numSelSellingNoBargain>0)
	{

	 $rowSelSellingNoBargain=mysql_fetch_array($rstSelSellingNoBargain);
	 $flagexpander=1;		
	 echo "<tr>
	       <td width='5%'$imageExpand</td>	
		   <td width='3%' height='28'>$sNo </td>					         
	       <td width='15%' ><a href='index.php?SellProduct=$productId' title='$productTitle'> ".wordFormater($products['product_name'],10)."</a></td>
		   <td width='9%' >".$products['pro_condition']."</td>
		   <td width='10%' align='center'>$numSelSellingNoBargain</td>
		   <td width='7%' >".$products['selling_type']."</td>
		   <td width='6%' align='center'>".$products['quantity']."</td>
		   <td width='11%' align='right'>".$rowSelSellingNoBargain['commission']."</td>
		   <td width='15%' align='right'>".$products['product_price']." $productShipping</td>
		   <td width='19%' >&nbsp;</td>
		   </tr>
		    ";	
	echo "<tr>
		  <td colspan='10'> <div style='border-top:1px solid #CCCCCC;'> </div> </td>
		  </tr>
		  ";
		  }
    $sqlSelSellingWithBargain="SELECT * FROM tbl_items where product_id='$productId' and bargained=1";
	$rstSelSellingWithBargain=mysql_query($sqlSelSellingWithBargain);				
	$numSelSellingWithBargain=mysql_num_rows($rstSelSellingWithBargain);
	if($numSelSellingWithBargain>0)
	{

	while($rowSelSellingWithBargain=mysql_fetch_array($rstSelSellingWithBargain))
	{
		if($flagexpander==0)
	  $imageExpand="<a href='javascript:void(0);' onClick='funContractProduct($productId,\"mchnt\",\"divSellingPro$productId\")'><img src='images/16x16x-.jpg'  border='0' ></a>";
	else
	   $imageExpand="";
	 echo "<tr>
		   <td width='5%'>$imageExpand</td>	
		   <td  width='3%' height='28'> $r </td>					         
	       <td width='15%' ><a href='index.php?SellProduct=$productId' title='$productTitle'> ".wordFormater($products['product_name'],10)."</a></td>
		   <td width='9%'>".$products['pro_condition']."</td>
		   <td width='10%' align='center'>1</td>
		   <td width='7%' >".$products['selling_type']."</td>
		   <td width='6%' align='center'>".$products['quantity']."</td>
		   <td width='11%'  align='right'>".$rowSelSellingWithBargain['commission']."</td>
		   <td width='15%' align='right'>".$rowSelSellingWithBargain['price']." $productShipping</td>
		   <td width='19%' >&nbsp;</td>
		   </tr>";
	echo "<tr>
		  <td colspan='10'> <div style='border-top:1px solid #CCCCCC;'> </div> </td>
		  </tr>";
		   $flagexpander=1;		
	}
	
	}
	echo "</table>";
  }
?>